#!/usr/bin/perl

open TAGS, "flickr_most_popular_tags" or die;
while (<TAGS>) {
    chomp;
    $cur = $_;
    $file = "google_result_pages/$_";
    open PAGE, $file or die "can't open $file";
    while (<PAGE>) {
        while (/<img src=\"(http:\/\/t\d.gstatic.com\/images\?q=tbn:.*?)\" height=\"\d*?\" width=\"\d*?\">/g) {
            system("echo \"$1\" >> thumbnail_urls/$cur");
        }    
    }
}
